<?php /* Smarty version Smarty-3.1.13, created on 2013-12-02 00:23:34
         compiled from "F:\PHP_WorkSapce\ibo123\templates\admin\ad\adsite.tpl" */ ?>
<?php /*%%SmartyHeaderCode:13001529b628609e090-24595724%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '4c81744ed2caa7d98a3248ca2e54e11f0b08953e' => 
    array (
      0 => 'F:\\PHP_WorkSapce\\ibo123\\templates\\admin\\ad\\adsite.tpl',
      1 => 1385048833,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '13001529b628609e090-24595724',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.13',
  'unifunc' => 'content_529b62865fffd7_37450386',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_529b62865fffd7_37450386')) {function content_529b62865fffd7_37450386($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ("admin/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/navibar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/sidebar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>



<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
public/assets/lib/ajaxupload.js"></script>

<style type="text/css">
#addwin {
	margin: -500px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">
	$(document).ready(function(){
		$('#win_add').window('close'); 
	});
	 
	function addWindow(){
		modelshow();
	}

	 function modelshow(){ 
		 $('#addwin').modal('show');
	 }
	 function modelhide(){
		 $('#addwin').modal('hide');
	 }
	function editWindow(){
		var select = getSelect();
		if(select == null || select.length == 0 ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}
		modelshow();
		$("#form").form('clear');
		$("#form").form('load',select[0]);
// 		$('#win_add').window('open'); 
// 		$("input[id='id']").val(select[0].id);
// 		$("select[id='type']").val(select[0].type);
// 		$("input[id='url']").val(select[0].url);
// 		$("input[id='imgname']").val(select[0].location);
// 		$("input[id='imgurl']").val(select[0].imgurl);
		
// 		$("textarea[id='desc']").val(select[0].desc);
// 		$("select[id='index']").val(select[0].index);
	}
	function deleteItem(){

		$.messager.confirm('Confirm','Delete the currently selected record!',function(r){
		    if (r){
		    	var select = getSelect();
				if(select == null || select.length == 0 ){
					$.messager.alert('ERROR','Please select the record!');
					return;
				}
				$.ajax({  
		            type: "POST",  
		            dataType: "json",  
		            url: '<?php echo @constant('WEBSITE_URL');?>
admin/adsite/delete',
		            data: { site_id: select[0].site_id },  
		            success: function (data) {  
		              //  $.messager.alert("消息", "删除成功!", "info");  
		             	$('#grid').datagrid('reload'); 
		            },  
		            error: function () {  
		            }  
		        });  
		    }
		});
		
	}

	
	function submitStatusChange(){
	    $.post(
				'<?php echo @constant('WEBSITE_URL');?>
admin/adsite/addOrModify',
				$('#form').serialize(),
				function(data){ 
					modelhide();
			    	$('#grid').datagrid('reload'); 
				},
				"json"
	    );
	}
	  

	function getSelect(){
		var select  = $("#grid").datagrid('getSelections');
		if(select == null || select.length == 0 ){
			return null;
		}
		return select;
	}

	function formateType(value,row,index){
		if(value == null || value ==""){
			return ""; 
		}
		if(value == 0){
			return "文字连接";
		}
		if(value == 1){
			return "图片连接";
		}
		if(value == 2){
			return "一段脚本";
		}
		 return "";
	}

	
 
</script>

<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">广告位置管理</h1>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">

			<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->
			<table id="grid"
				data-options="url:'<?php echo @constant('WEBSITE_URL');?>
admin/adsite/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: 700px; height: 370px"
				toolbar="#toolbar" iconCls="icon-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<th data-options="field:'site_id',width:100,checkbox:true"></th>
						<th data-options="field:'site_name',width:100">位置名称</th>
						<th data-options="field:'site_description',width:100">位置描述</th>
						<!-- 						<th data-options="field:'site_parent',width:100"></th> -->
						<th
							data-options="field:'site_type',width:100,formatter:formateType">位置类型</th>
					</tr>
				</thead>
			</table>

			<div id="toolbar">
				<a href="#" class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="addWindow()">添加</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-edit" plain="true"
					onclick="editWindow()">修改</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-remove" plain="true"
					onclick="deleteItem()">删除</a>
			</div>

			<div id="addwin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>位置信息管理</h5>
				</div>
				<div class="modal-body">
					<form class=" form-horizontal" id="form">
						<input id="site_id" name="site_id" type="text"
							style="display: none;">
						<div class="control-group">
							<label class="control-label">位置名称:</label>
							<div class="controls">
								<input id="site_name" type="text" placeholder="位置名称"
									name="site_name">
							</div>
						</div>


						<div class="control-group">
							<label class="control-label">位置类型:</label>
							<div class="controls">
								<select id="site_type" name="site_type">
									<option value="0">文字连接</option>
									<option value="1">图片连接</option>
									<option value="2">一段脚本</option>
								</select>
							</div>
						</div>

						<div class="control-group">
							<label class="control-label">位置描述:</label>
							<div class="controls">
								<textarea id="site_description" rows="2" type="text"
									placeholder="位置描述" name="site_description">
							</textarea>
							</div>
					
					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button class="btn btn-success" onclick="submitStatusChange()"
						type="button" style="width: 100px; align: right;" class="btn">提交</button>
					<button class="btn" onclick="modelhide()" type="button"
						style="width: 100px; align: right;">取消</button>

				</div>
			</div>
			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			<?php echo $_smarty_tpl->getSubTemplate ("admin/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
<?php }} ?>